package com.haofengsoft.platform.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 15-3-13.
 */
public class PhoneUtil {
    /* 验证手机号码
    * @param mobiles
    * @return  [0-9]{5,9}
    */
    public static boolean isMobileNO(String mobiles) {
        boolean flag = false;
        try {
            String expression = "((^(13|14|15|17|18|)[0-9]{9}$)|(^0[1,2]{1}\\d{1}-?\\d{8}$)|(^0[3-9] {1}\\d{2}-?\\d{7,8}$)|(^0[1,2]{1}\\d{1}-?\\d{8}-(\\d{1,4})$)|(^0[3-9]{1}\\d{2}-? \\d{7,8}-(\\d{1,4})$))";
            Pattern p = Pattern.compile(expression);
            Matcher m = p.matcher(mobiles);
            flag = m.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
}
